package com.sunyard.manage.controller;

import com.sunyard.constant.ErrMessageConst;
import com.sunyard.dal.bo.PaginationBO;
import com.sunyard.dal.bo.warning.WarningInfoQueryBO;
import com.sunyard.dal.dto.WarningInfoDTO;
import com.sunyard.manage.service.WarningInfoService;
import com.sunyard.utils.Response.BaseResult;
import com.sunyard.utils.Response.GetResult;
import com.sunyard.utils.manage.DataGrid;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wxl
 * @date 2022-07-11
 */
@Slf4j
@RestController
@RequestMapping(value = "/warningInfo", method = RequestMethod.POST)
@Api(tags = "WarningInfoController", description = "预警信息")
public class WarningInfoController {

    @Autowired
    WarningInfoService warningInfoService;

    /**
     * @Description: PC端管理平台预警统计-预警信息（按照机构查询出当前机构下发生预警的日志）
     * @author wxl
     * @date 2022年7月11日
     */
    @ResponseBody
    @ApiOperation("预警信息查询")
    @RequestMapping(value = "/queryWarningInfo", method = RequestMethod.POST)
    public BaseResult<DataGrid<WarningInfoDTO>> queryWarningInfo(@RequestBody PaginationBO<WarningInfoQueryBO> queryBO, HttpServletRequest request) {
        try {
            return warningInfoService.queryWarningInfo(queryBO, request);
        } catch (Exception e) {
            log.error(ErrMessageConst.SYSTEM_ERROR, e);
            return GetResult.getResultErr();
        }
    }
}
